﻿<%@ Page CodeFileBaseClass="AliCMS.Lib.SystemPageBase" %>
<script language="c#" runat="server">
protected string Condition()
{
	StringBuilder condition = new StringBuilder();
	string and = String.Empty;

	#region 开始日期
	string startTime = Request.QueryString["StartTime"];
	if (!String.IsNullOrEmpty(startTime))
		condition.Append(and + Alias.Click.Time + " >= #" + startTime + "#");
	#endregion

	if (and == String.Empty && condition.Length != 0)
		and = " AND ";

	#region 结束日期
	string endTime = Request.QueryString["EndTime"];
	if (!String.IsNullOrEmpty(endTime))
		condition.Append(and + Alias.Click.Time + " <= #" + endTime + "#");
	#endregion

	if (and == String.Empty && condition.Length != 0)
		and = " AND ";

	#region 关键词
	string keyword = Request.QueryString["Keyword"];
	if (!String.IsNullOrEmpty(keyword))
	{
		if (Request.QueryString["KeywordType"] == "PositionName")
			condition.Append(and + Alias.Click.PositionName + " LIKE '%" + keyword + "%'");
		else if (Request.QueryString["KeywordType"] == "PositionInnerID")
			condition.Append(and + Alias.Click.PositionInnerID + "=" + keyword);
		else if (Request.QueryString["KeywordType"] == "Advertiser")
			condition.Append(and + Alias.Click.Advertiser + " LIKE '%" + keyword + "%'");
		else if (Request.QueryString["KeywordType"] == "AdTitle")
			condition.Append(and + Alias.Click.AdTitle + " LIKE '%" + keyword + "%'");
	}
	#endregion
	
	return condition.ToString();
}
</script>
<section data-page="income_cpc" data-title="按点击计费" data-lang="<%=ContentLang%>">
	<dl class="path1">
		<dt><span>您的位置：</span>按点击计费</dt>
		<dd>
			<select data-ali-widget="combo" data-class="<%=ContentLang%>Font">
				<ali:List Mark="System" Object="Language" Source="Manager.Languages">
					<ali:Record>
						<%If Convert.ToString(Ab) == ContentLang%>
							<option value="<%=Ab%>" selected><%=[AliCMS.SystemModule.Alias.Language.Name + PageLang]%></option>
						<%Else%>
							<option value="<%=Ab%>"><%=[AliCMS.SystemModule.Alias.Language.Name + PageLang]%></option>
						<%EndIf%>
					</ali:Record>
				</ali:List>
			</select>
		</dd>
	</dl>
	<div class="ali-tabs sub-nav" data-height-style="fill" data-event="click">
		<div class="ali-tabs-header">
			<div class="ali-tabs-nav-container">
				<ul>
					<li class="ali-active"><a>按点击计费</a></li>
					<li><a href="cpt.aspx?Lang=<%=ContentLang%>" target="ali-navtab">按时长计费</a></li>
					<li><a href="clicks.aspx?Lang=<%=ContentLang%>" target="ali-navtab">点击清单</a></li>
					<li><a href="list.aspx?Lang=<%=ContentLang%>" target="ali-navtab">收入清单</a></li>
				</ul>				
			</div>
		</div>
		<div class="ali-tabs-body">
			<div class="ali-tabs-panel">
				<form action="?Lang=<%=ContentLang%>" class="search1">
					从：<input type="text" size="12" name="StartTime" readonly class="ali-input" data-ali-widget="calendar">
					到：<input type="text" size="12" name="EndTime" readonly class="ali-input" data-ali-widget="calendar">
					关键词：<input name="Keyword" class="ali-input <%=ContentLang%>Font">
					<select name="KeywordType" data-ali-widget="combo" data-class="<%=ContentLang%>Font">
						<option value="PositionName">广告位名称</option>
						<option value="PositionInnerID">广告位编号</option>
						<option value="Advertiser">广告主</option>
						<option value="AdTitle">广告标题</option>
					</select>
					<button type="submit" class="ali-button">搜索</button>
				</form>
				<div class="content">
					<table data-ali-widget="grid" class="grid1">
						<thead>
							<tr>
								<th>广告位</th>
								<th>广告</th>
								<th>广告主</th>
								<th>点击单价（元）</th>
								<th>点击数</th>
								<th>收入</th>
								<th>结算</th>
							</tr>
						</thead>
						<tbody>
							<ali:List ID="List" Object="Click" Operation="ListCpc" Page="PageNumber" PageSize="PageSizeValue" Condition="Condition()" Validate="True">
								<ali:Record>
									<tr data-id="<%=InnerID%>">
										<td class="<%=ContentLang%>Font"><a href="../position/edit.aspx?Lang=<%=ContentLang%>&amp;ID=<%=PositionInnerID%>" target="ali-navtab"><%=PositionName%></a></td>
										<td class="<%=ContentLang%>Font"><a href="../ad/edit.aspx?Lang=<%=ContentLang%>&amp;ID=<%=AdInnerID%>" target="ali-navtab"><%=AdTitle%></a></td>
										<td><%=Advertiser%></td>
										<td><%=ClickPrice%></td>
										<td><%=HitCount%></td>
										<td><%=Convert.ToDecimal(ClickPrice) * Convert.ToInt32(HitCount)%></td>
										<td><a href="" class="ali-button" data-operation="Settle">结算</a></td>
									</tr>
								</ali:Record>
							</ali:List>
						</tbody>
					</table>
					<ali:Pagination Page="PageNumber" PageSize="PageSizeValue" RecordCount="List[RecordCount]">
						<div class="pagination1" data-page-number="<%=PageNumber%>" data-page-count="<%=PageCount%>" data-page-size="<%=PageSize%>">
							<div class="pagination1-left">
								共<b><%=PageCount%></b>页，每页显示
									<select name="PageSize" data-ali-widget="combo">
										<option value="20">20</option>
										<option value="50">50</option>
										<option value="100">100</option>
										<option value="200">200</option>
									</select>条，共<b><%=RecordCount%></b>条记录
							</div>
							<ul class="pagination1-right">
								<ali:FirstPage>
									<ali:Yes>
										<li><span><span class="first disabled">首页</span></span></li>
										<li><span><span class="prev disabled">上一页</span></span></li>
									</ali:Yes>
									<ali:No>
										<li><a href="1"><span class="first">首页</span></a></li>
										<li><a href="<%=PageNumber - 1%>"><span class="prev">上一页</span></a></li>
									</ali:No>
								</ali:FirstPage>
								<ali:CurrentPage Range="5">
									<ali:Yes>
										<li class="active"><span><%=Index%></span></li>
									</ali:Yes>
									<ali:No>
										<li><a href="<%=Index%>"><%=Index%></a></li>
									</ali:No>
								</ali:CurrentPage>
								<ali:LastPage>
									<ali:Yes>
										<li><span><span class="next disabled">下一页</span></span></li>
										<li><span><span class="last disabled">末页</span></span></li>
									</ali:Yes>
									<ali:No>
										<li><a href="<%=PageNumber + 1%>"><span class="next">下一页</span></a></li>
										<li><a href="<%=PageCount%>"><span class="last">末页</span></a></li>
									</ali:No>
								</ali:LastPage>
			
								<li class="go">
									<input type="text" name="PageNumber" value="1" size="4"><button></button>
								</li>
							</ul>
						</div>
					</ali:Pagination>
				</div>
			</div>
		</div>
		<div class="ali-tabs-bottom"><b></b></div>
	</div>
</section>